#include "Pch.h"

#include "TestCase.h"


TestCase::TestCase()
{}


void TestCase::Run()
{
    m_iniFile.LoadFromFile( Swprintf( L"%s.ini", this->GetName() ));

    const IniSection* executor = m_iniFile.GetSection( L"Executor" );
    const Uint type = executor->GetUintValue( L"Type" );
    switch ( type )
    {
    case 1:
    {
        Task::WorkerThread* wthread = new Task::WorkerThread;
        wthread->Startup( "Worker" );
        m_executor.reset( wthread );
        break;
    }

    default:
        ISHTAR_TRACE_FAIL( "Unknown executor type" );
        ISHTAR_TRACE_INFO( "  type: %u", type );
        ISHTAR_INVALID_OPERATION();
    }

    this->DoRun();

    m_threads.Shutdown();
    m_executor->Shutdown();

    m_stopped = true;
}


void TestCase::Stop()
{
    m_stopped = true;
}


const IniSection* TestCase::GetBuildSection() const
{
    #if defined( _DEBUG )
    return m_iniFile.GetSection( L"Debug" );
    #else
    return m_iniFile.GetSection( L"Release" );
    #endif
}
